Skip to content

refactor: move AttributeReference and KnownFloatingPointNormalized expression support checks to getSupportLevel#4745

Merged
andygrove merged 3 commits into
apache:mainfrom
peterxcli:misc-scalar-serdes
Jul 17, 2026
Merged

refactor: move AttributeReference and KnownFloatingPointNormalized expression support checks to getSupportLevel#4745
andygrove merged 3 commits into
apache:mainfrom
peterxcli:misc-scalar-serdes

Conversation

@peterxcli

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #4673.

Rationale for this change

This finishes the misc scalar serde follow-up for #4673. These serdes still had static support decisions in convert, even though the dispatcher expects those decisions to come from getSupportLevel.

Binding-dependent failures and child fallback rollups still stay in convert.

What changes are included in this PR?

Move static support checks into getSupportLevel for:

  • AttributeReference: unsupported data types.
  • FromUnixTime: unsupported native datetime format when the incompatible native path is enabled, while keeping the default codegen-dispatch path unchanged.
  • KnownFloatingPointNormalized: unsupported wrapped child data types.

The remaining withFallbackReason calls in these files are for child conversion or binding-dependent failures.

How are these changes tested?

Added focused coverage in CometExpressionSuite for the misc scalar serde getSupportLevel decisions.

Also ran:

./mvnw test -Pspark-3.5 -Pscala-2.12 -Dtest=none -Dsuites="org.apache.comet.CometExpressionSuite misc scalar serdes report static unsupported cases via getSupportLevel" -Dscalastyle.skip=true

@peterxcli peterxcli changed the title Report unsupported scalar serde cases in support level refactor: move AttributeReference, FromUnixTime and KnownFloatingPointNormalized expression support checks to getSupportLevel Jun 28, 2026
override def getSupportLevel(expr: FromUnixTime): SupportLevel = Incompatible(None)
override def getSupportLevel(expr: FromUnixTime): SupportLevel = {
if (expr.format == Literal(TimestampFormatter.defaultPattern()) ||
!CometConf.isExprAllowIncompat(getExprConfigName(expr))) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about the reference to isExprAllowIncompat here. Typically we would just return Incompatible and then rely on the serde framework checkign this flag.

// TODO: DataFusion supports only -8334601211038 <= sec <= 8210266876799
// https://github.com/apache/datafusion/issues/16594
object CometFromUnixTime extends CometExpressionSerde[FromUnixTime] with CodegenDispatchFallback {
private val unsupportedFormatReason = "Datetime pattern format is unsupported"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you implement getUnsupportedReasons, referencing unsupportedFormatReason so that this gets generated into the docs?

@peterxcli
peterxcli requested a review from andygrove July 12, 2026 13:14
@peterxcli
peterxcli marked this pull request as ready for review July 12, 2026 13:16
@peterxcli peterxcli changed the title refactor: move AttributeReference, FromUnixTime and KnownFloatingPointNormalized expression support checks to getSupportLevel refactor: move AttributeReference and KnownFloatingPointNormalized expression support checks to getSupportLevel Jul 12, 2026
@peterxcli

Copy link
Copy Markdown
Member Author

@andygrove looks like the above two comments have been addressed in your pr #4847, I have merged the upstream main, please take another looks on the refactor for AttributeReference and KnownFloatingPointNormalized expr. Thanks!

@andygrove andygrove left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @peterxcli

@andygrove

Copy link
Copy Markdown
Member

This looks good and reads as a faithful move of the static datatype checks into getSupportLevel. I confirmed the .get calls in convert are safe, since the framework only calls convert on the Compatible branch and both serdes return Compatible() exactly when serializeDataType is defined.

Two small things, neither blocking:

  • The PR description still mentions the FromUnixTime change, but that is not in this diff anymore (it went to fix: report FromUnixTime non-default format as Unsupported #4847). Could you trim the body so the changelog stays accurate?
  • While you are touching both messages, it might be nice to align the casing. AttributeReference produces "unsupported datatype:" and KnownFloatingPointNormalized produces "Unsupported datatype".

This review was prepared with the assistance of an LLM (Claude).

@andygrove

Copy link
Copy Markdown
Member

This looks good and reads as a faithful move of the static datatype checks into getSupportLevel. I confirmed the .get calls in convert are safe, since the framework only calls convert on the Compatible branch and both serdes return Compatible() exactly when serializeDataType is defined.

Two small things, neither blocking:

  • The PR description still mentions the FromUnixTime change, but that is not in this diff anymore (it went to fix: report FromUnixTime non-default format as Unsupported #4847). Could you trim the body so the changelog stays accurate?
  • While you are touching both messages, it might be nice to align the casing. AttributeReference produces "unsupported datatype:" and KnownFloatingPointNormalized produces "Unsupported datatype".

This review was prepared with the assistance of an LLM (Claude).

Sorry, ignore this. I'm happy to merge once CI is green.

@andygrove
andygrove merged commit a469fc6 into apache:main Jul 17, 2026
131 of 132 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move static support decisions from serde convert into getSupportLevel

2 participants